﻿/// ****************************************************************************
/// Author:	        Robin Zhu
/// Create Date:	2012-4-24
/// Purpose: 		WCF实现版本的客户端的配置节类
/// ****************************************************************************
/// Modify By		Date			Remark
/// ****************************************************************************
/// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace RB.Web.Security.Wcf
{
    /// <summary>
    /// WCF实现版本的客户端的配置节类
    /// </summary>
    public class WcfSecurityConfigSection : ConfigurationSection
    {
        private static WcfSecurityConfigSection _current = (WcfSecurityConfigSection)ConfigurationManager.GetSection("RB.WcfSecurity");

        public static WcfSecurityConfigSection Current
        {
            get
            {
                return _current;
            }
        }

        internal string GetServiceAddress(string serviceName)
        {
            if (!RemoteAddress.EndsWith("/"))
                return RemoteAddress + "/" + serviceName;
            return RemoteAddress + serviceName;
        }

        [ConfigurationProperty("remoteAddress", IsRequired = true)]
        public string RemoteAddress
        {
            get
            {
                return (string)this["remoteAddress"];
            }
            set
            {
                this["remoteAddress"] = value;
            }
        }
    }
}
